import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '机构id',
    align: 'center',
    dataIndex: 'id',
    width: '250px'
  },
  {
    title: '医院名称',
    align: 'center',
    dataIndex: 'name',
    width: '200px'
  },
  {
    title: '医院logo',
    align: 'center',
    dataIndex: 'logo',
    customRender: render.renderImage,
  },
  {
    title: '医院等级',
    align: 'center',
    dataIndex: 'level_dictText'
  },
    {
    title: '机构编码',
    align: 'center',
    dataIndex: 'sysOrgCode'
  },
  {
    title: '旧机构编码',
    align: 'center',
    dataIndex: 'oldNum'
  },
  {
    title: '状态',
    align: 'center',
    dataIndex: 'status_dictText',
  },
  {
    title: '店铺ID',
    align: 'center',
    dataIndex: 'shopid',
  },
  {
    title: '地区',
    align: 'center',
    dataIndex: 'area'
  },
  {
    title: '医院地址',
    align: 'center',
    dataIndex: 'address'
  },
  // {
  //   title: '经纬度',
  //   align: 'center',
  //   dataIndex: 'uldlatlnt'
  // },
  {
    title: '经度',
    align: 'center',
    dataIndex: 'longitude'
   },
   {
    title: '纬度',
    align: 'center',
    dataIndex: 'latitude'
   },
  {
    title: '创建人',
    align: 'center',
    dataIndex: 'createBy'
  },
  {
    title: '创建日期',
    align: 'center',
    dataIndex: 'createTime'
  },
  {
    title: '更新人',
    align: 'center',
    dataIndex: 'updateBy'
  },
  {
    title: '更新日期',
    align: 'center',
    dataIndex: 'updateTime'
  },
  {
    title: '开票点',
    align: 'center',
    dataIndex: 'billCode_dictText'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "机构id",
    field: "id",
    component: 'JSearchSelect',
    componentProps: {
      dict: "nurse_hospital,name,id",
      placeholder: '请选择机构',
    },
    //colProps: {span: 6},
  },
  {
    label: "医院名称",
    field: "name",
    component: 'JInput',
    //colProps: {span: 6},
  },
  {
    label: "状态",
    field: "status",
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "valid_status"
    },
    //colProps: {span: 6},
  },
  {
    label: "机构编码",
    field: "sysOrgCode",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "旧机构编码",
    field: "oldNum",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "开票点",
    field: "billCode",
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "nurse_bill_point,name,code"
    },
    //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '医院名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入医院名称!' },
      ];
    },
  },
  {
    label: '医院logo',
    field: 'logo',
    component: 'JImageUpload',
    componentProps: {
    },
  },
  {
    label: '父级节点',
    field: 'pid',
    component: 'JTreeSelect',
    componentProps: {
      dict: "nurse_hospital,name,id",
      pidField: "pid",
      pidValue: "0",
      hasChildField: "has_child",
    },
  },
  {
    label: '店铺ID',
    field: 'shopid',
    component: 'Input',
  },
    {
    label: '机构编码',
    field: 'sysOrgCode',
    component: 'Input',
  },
  {
    label: '旧机构编码',
    field: 'oldNum',
    component: 'Input',
  },
  {
    label: '医院等级',
    field: 'level',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "nurse_hospital_level"
    },
  },
  {
    label: '地区',
    field: 'area',
    component: 'Input',
  },
  {
    label: '医院地址',
    field: 'address',
    component: 'Input',
  },
  // {
  //   label: '经纬度',
  //   field: 'uldlatlnt',
  //   component: 'Input',
  // },
  {
    label: '经度',
    field: 'longitude',
    component: 'Input',
  },
  {
    label: '纬度',
    field: 'latitude',
    component: 'Input',
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    defaultValue: "1",
    componentProps: {
      dictCode: "valid_status"
    },
  },
  {
    label: '开票点',
    field: 'billCode',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "nurse_bill_point,name,code"
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '机构id',
    field: 'id',
    component: 'Input',
    componentProps: {
      disabled: true,
      placeholder: '系统自动生成'
    }
  },
];

// 高级查询数据
export const superQuerySchema = {
  id: { title: '机构id', order: 0, view: 'text', type: 'string' },
  createBy: { title: '创建人', order: 1, view: 'text', type: 'string', },
  createTime: { title: '创建日期', order: 2, view: 'datetime', type: 'string', },
  updateBy: { title: '更新人', order: 3, view: 'text', type: 'string', },
  updateTime: { title: '更新日期', order: 4, view: 'datetime', type: 'string', },
  name: { title: '医院名称', order: 5, view: 'text', type: 'string', },
  logo: { title: '医院logo', order: 6, view: 'image', type: 'string', },
  level: { title: '医院等级', order: 7, view: 'list', type: 'string', dictCode: 'nurse_hospital_level', },
  sysOrgCode: { title: '机构编码', order: 8, view: 'text', type: 'string', },
  oldNum: { title: '旧机构编码', order: 9, view: 'text', type: 'string', },
  area: { title: '地区', order: 10, view: 'text', type: 'string', },
  address: { title: '医院地址', order: 11, view: 'text', type: 'string', },
  //uldlatlnt: { title: '经纬度', order: 10, view: 'text', type: 'string', },
  status: { title: '状态', order: 12, view: 'radio', type: 'string', },
  billCode: { title: '开票点', order: 13, view: 'list', type: 'string', dictTable: "nurse_bill_point", dictCode: 'code', dictText: 'name', },
  longitude: {title: '经度',order: 14,view: 'text', type: 'string',},
  latitude: {title: '纬度',order: 15,view: 'text', type: 'string',},
};


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
